package com.ny.zmb.openapi.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

@TableName(value = "pm_user_wallet_log")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class PmUserWalletLog implements Serializable {

    @TableField("id")
    @TableId(type = IdType.AUTO)
    private Integer id;

    private String moneyType;

    private Integer userId;

    private BigDecimal money;

    private BigDecimal beforeMoney;

    private BigDecimal afterMoney;

    private String memo;

    private Integer tag;

    private String targetId;

    private Integer createtime;

    @TableField(exist = false)
    private String create_time;

    public String getCreate_time() {
        if (null != this.createtime){
            Long q = 1000L;
            Long result = this.createtime  * q;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return sdf.format(new Date(result));
        }
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }
}
